﻿using System;
using System.IO;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using webapp4U.DAL;

using System.Web.UI;

namespace webapp4U.BOL
{
    public class Board : BizObject
    {
        #region "---Properties---"
        private int _boardID;
        private string _imageURL;
       private string _information;
       
               
        public int BoardID
        {
            get { return _boardID; }
            set { _boardID = value; }
        }

       
        public string ImageURL
        {
            get { return _imageURL; }
            set { _imageURL = value; }
        }
            
            
        public string Information
        {
            get { return _information; }
            set { _information = value; }
        }
                

        #endregion

        public Board()
        {
        
        }
        
       
       
        //Get All Board
        public static List<Board> GetAllBoard()
        {
            BoardDAL db = new BoardDAL();
            return db.GetAllBoard(1, MAXROWS);
        }

        //Get All Board
        public static List<Board> GetAllBoard(int PageIndex, int PageSize)
        {
            BoardDAL db = new BoardDAL();
            return db.GetAllBoard(PageIndex, PageSize);
        }

        // Get Count All records of Table  Board
        public static int GetCountBoard()
        {
            BoardDAL db = new BoardDAL();
            return db.GetCountBoard();
        }


        public static string GetImageURLByBoardID(int BoardID)
        {
            BoardDAL db = new BoardDAL();
            return db.GetImageURLByBoardID(BoardID);
        }

        
        

        public static Board GetBoardByBoardID(int BoardID)
        {
            BoardDAL db = new BoardDAL();
            return db.GetBoardByBoardID(BoardID);
        }
                
        
        public static int Insert(Board obj)
        {
            BoardDAL db = new BoardDAL();
            return db.Insert(obj);
        }


        public static int Update(Board obj)
        {
            BoardDAL db = new BoardDAL();
            return db.Update(obj);
        }


        public static int Delete(int BoardID)
        {
            // xoa hinh truoc
            FileProcess.DeleteFile(Globals.PhysicalApplicationPath() + "UserUpload/Board/" + GetImageURLByBoardID(BoardID));
            BoardDAL db = new BoardDAL();
            return db.Delete(BoardID);
        }

       
    }
}